package com.springboot.springautowired.beanlifecircle;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.context.*;
import org.springframework.context.annotation.ImportAware;
import org.springframework.context.weaving.LoadTimeWeaverAware;
import org.springframework.core.env.Environment;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.instrument.classloading.LoadTimeWeaver;
import org.springframework.util.StringValueResolver;
import org.springframework.web.context.ServletContextAware;

import javax.servlet.ServletContext;

/**
 * @author mac
 * @date 2021/9/15 4:55 下午
 */
public class AllWareTest implements BeanNameAware, BeanClassLoaderAware, BeanFactoryAware, EnvironmentAware, EmbeddedValueResolverAware,
        ResourceLoaderAware, ApplicationEventPublisherAware, MessageSourceAware,ApplicationContextAware, ServletContextAware, LoadTimeWeaverAware,
        ImportAware {
    @Override
    public void setBeanClassLoader(ClassLoader classLoader) {
        //设置当前bean的类加载器
    }

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        //设置bean工厂  如果使用@Configuration注解的话这个方法会被执行两次
    }

    @Override
    public void setBeanName(String s) {
        //返回当前beanName
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        //获取bena的方式之一 这是设置当前applicationcontext对象的
    }

    @Override
    public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {

    }

    @Override
    public void setEmbeddedValueResolver(StringValueResolver stringValueResolver) {
        //获取value表达式在配置文件中的具体配置信息
    }

    @Override
    public void setEnvironment(Environment environment) {
        //工程启动时可以获取application.properties、xml、yml配置文件中的配置项
    }

    @Override
    public void setMessageSource(MessageSource messageSource) {

    }

    @Override
    public void setResourceLoader(ResourceLoader resourceLoader) {

    }

    @Override
    public void setImportMetadata(AnnotationMetadata annotationMetadata) {

    }

    @Override
    public void setLoadTimeWeaver(LoadTimeWeaver loadTimeWeaver) {

    }

    @Override
    public void setServletContext(ServletContext servletContext) {

    }
}
